### Makefile --- xml<-->sql 

## Version: $Id: Makefile 5 2007-03-11 21:33:07Z fvamail $

.PHONY	: all

all: drop.sql

drop.sql : init.sql Makefile
	grep -i -E -o '^create +(or +replace +)?(((index|table|sequence|view|type) +[^ ]+)|function +[^ (]+ *\([^)]*\)|aggregate +[^ (]+ *\( *BASETYPE *= *[^ ]*)' $< | \
	sed 's/\(aggregate \+[^ (]\+ *( *\)BASETYPE *= *\([^ ]*\)/\1\2 )/' | \
	sed 's/^create\( \+or \+replace\)\?/drop/' | \
	sed 's/$$/ ;/' | tac >$@


%.txt : %.sql
	cp $< $@


%.html : %.txt
	rst2html \
		--stylesheet=rst.css \
		--embed-stylesheet \
		--no-xml-declaration \
		--generator \
		--time \
		$< $@

%.tex : %.txt
	rst2latex.py \
		--generator --time \
		--font-encoding=T2A \
		--language=ru \
		--output-encoding=utf-8 \
		--documentoptions=11pt,a4paper,unicode \
		--documentclass=article \
		--use-latex-toc \
		$< $@

%.dvi : %.tex
	texi2dvi --quiet --language=LaTeX $< $@

%.ps	: %.dvi
	dvips -o $@ -j0 -Pamz -Pcmz $<

%.pdf : %.tex
	pdflatex $<
	pdflatex $<
	pdflatex $<


### Makefile ends here
